package entities;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import api.entitites.Entities;
import api.entitites.IGarage;
import api.entitites.IMaster;
import api.entitites.IOrder;
import api.entitites.OrderStatus;


@Entity
@Table(name="orders")
public class Order implements IOrder, Cloneable,Entities{

	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="id_order")
	private Integer id;
	
	@Column(name="number_order")
	private Integer number;
	
	@Column(name="status_order")
	private OrderStatus orderstatus = null;
	
	@Column(name="filling_date")
	@Temporal(value=TemporalType.DATE)
	private Date fillingdate;
	
	@Column(name="begining_date")
	@Temporal(value=TemporalType.DATE)
	private Date beginingdate;
	
	@Column(name="deadline_date")
	@Temporal(value=TemporalType.DATE)
	private Date deadlinedate;
	
	@Column(name="price")
	private Integer price;
	
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY,targetEntity=Master.class)
	@JoinColumn(name="id_master")
	private IMaster master;
	
	@OneToOne(cascade=CascadeType.ALL,fetch=FetchType.LAZY, targetEntity=Garage.class)
	@JoinColumn(name="id_garage")
	private IGarage garage;
		

	public Integer getId() {
		return id;
	}

	public void setIdOrder(Integer idOrder) {
		this.id = idOrder;
	}

	public int getNumber() {
		return number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	public Date getFillingDate() {
		return fillingdate;
	}

	public void setFillingDate(Date fillingDate) {
		this.fillingdate = fillingDate;
	}

	public Date getBeginingDate() {
		return beginingdate;
	}

	public void setBeginingDate(Date beginingDate) {
		this.beginingdate = beginingDate;
	}

	public Date getDeadlineDate() {
		return deadlinedate;
	}

	public void setDeadlineDate(Date deadlineDate) {
		this.deadlinedate = deadlineDate;
	}

	public Integer getPrice() {
		return price;
	}

	public void setPrice(Integer price) {
		this.price = price;
	}

	public IMaster getMaster() {
		return master;
	}

	public void setMaster(IMaster master) {
		this.master = master;
	}

	public IGarage getGarage() {
		return garage;
	}

	public void setGarage(IGarage garage) {
		this.garage = garage;
	}
	

	public void setOrderStatus(OrderStatus ordSt) {
		this.orderstatus = ordSt;
				
	}

	public OrderStatus getOrderStatus() {
		return orderstatus;
		
	}

	public void shiftTime(Date deadlineDate) {
		this.deadlinedate = deadlineDate;
	}

	public IOrder cloneOrder() throws CloneNotSupportedException {
		
		return (IOrder) super.clone();
		
		
	}

}
